package com.hardware.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hardware.common.BaseContext;
import com.hardware.dto.ShopDto;
import com.hardware.entity.Purchase;
import com.hardware.mapper.PurchaseMapper;
import com.hardware.service.PurchaseService;
import com.hardware.service.SupplierService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class PurchaseServiceImpl extends ServiceImpl<PurchaseMapper,Purchase> implements PurchaseService {


    /**
     * 新增订单
     * @param shopDto
     */
    @Override
    public void add(ShopDto shopDto) {
        Purchase purchase = new Purchase();
        purchase.setShopId(shopDto.getId());
        purchase.setNumber(shopDto.getStock());
        purchase.setSupplierId(shopDto.getSupplierId());
        purchase.setSupplierCompany(shopDto.getSupplierCompany());
        purchase.setEmployeeId(BaseContext.getCurrentId());

        save(purchase);

    }
}
